
from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from users.models import User
from django.contrib.auth.models import Group
from meiduo_admin.serializers.admin_serializers import *
from meiduo_admin.custom_paginations import MyPage
from meiduo_admin.serializers.group_serializers import GroupModelSerializer

class AdminUserViewSet(ModelViewSet):
    # select * from users_user where is_staff=1;
    # queryset本质上保存的是一个还未执行的sql
    queryset = User.objects.filter(is_staff=True)
    serializer_class = AdminUserModelSerializer
    pagination_class = MyPage



class AdminGroupListView(ListAPIView):
    queryset = Group.objects.all()
    serializer_class = GroupModelSerializer